package com.shujia.flink.source

import org.apache.flink.streaming.api.scala._

object Demo1FileSource {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    /**
      * 读取文件构建DS - - 有界流
      *
      */

    val studentDS: DataStream[String] = env.readTextFile("data/students.txt")

    studentDS
      .map(stu => {
        val clazz: String = stu.split(",")(4)
        (clazz, 1)
      })
      .keyBy(_._1)
      .sum(1)
      .print()

    env.execute()

  }

}
